<!-- 上市情况 -->
<template>
  <div v-loading="loading">
    <div class="chartDom" style="width: 100%;height: 300px;">
      <barLineChart v-if="chartData.datas.length > 0" :chart-data="chartData" height="100%" @clickHandel="changeStage" />
      <div v-else class="noneData">
        <div>
          <svg-icon icon-class="none" class-name="none-icon" />
          <p>{{ $t('暂无数据') }}</p>
        </div>
      </div>
    </div>
    <div class="list-table">
      <div class="area-header">
        <indirectProjectSummary ref="indirectProjectSummary" />
      </div>
    </div>
  </div>
</template>

<script>
import indirectProjectSummary from '@/views/deal/bf/indirectProjectAnalysis/indirectProjectSummary.vue'
import barLineChart from '@/views/chart/barLineChart.vue'
import { getListingEcharts } from '@/api/bf/indirectProjectAnalysis/indirectProjectSummary'

export default {
  components: {
    indirectProjectSummary,
    barLineChart
  },
  data() {
    return {
      loading: false,
      chartData: {
        datas: []
      },
      bfGroupListedSituation: []
    }
  },
  created() {
  },
  mounted() {
    this.load()
  },
  methods: {
    load() {
      this.loading = true
      this.getDicts('bf_group_listed_situation').then(response => {
        this.bfGroupListedSituation = response.data
        getListingEcharts().then(res => {
          var title = []
          var _data = []
          for (const key in res.data) {
            var temp = this.bfGroupListedSituation.find(obj => obj.dictValue === key)
            title.push(temp.dictLabel)
            _data.push({ value: res.data[key], name: temp.dictLabel, type: key })
          }
          this.chartData.xLabel = title
          this.chartData.datas = [
            {
              type: 'bar',
              name: '',
              data: _data
            }
          ]
          this.loading = false
        })
      })
      this.changeStage('notNull')
    },
    changeStage(val) {
      this.$nextTick(() => {
        const temp = this.bfGroupListedSituation.find(obj => obj.dictLabel === val.type)
        this.$refs.indirectProjectSummary.parentQueryParams.listedSituation = temp === undefined ? val.type : temp.dictValue
        this.$refs.indirectProjectSummary.getList()
      })
    }
  }
}
</script>

<style scoped>

</style>
